package edu.java基础;

public class R_二维数组 {
    public static void main(String[] args) {
        //定义：int[][] arr;
        //int arr[][];  int[] arr[];

        //动态初始化
        /*
        int[][] arr = new int[2][3];//能包含两个一维数组，每个一维数组能存3个数
        System.out.println(arr); //[[I@43a25848
        */
        /*
        [[I@43a25848 :I表示整型，[[有几个中括号就是几维数组
        */

        //二维数组存储一组数据，存储的是一维数组的内存地址
       /* System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);*/

        /*
        int[] arr1={11,22,33};
        int[] arr2={12,22,33};
        int[] arr3={13,22,33};
        int[][] arr=new int[3][3];
        arr[0]=arr1;
        arr[1]=arr2;
        arr[2]=arr3;
        */

        //int[][] arr = new int[3][3];
       /* arr[0][3]=11;
        System.out.println(arr[0][3]);
        */ //会出现索引越界

        //int[] smallArray = {111,222,333,444,555};
        //arr[2]=smallArray;//把arr在栈内存中存储的地址值给替换了
        //System.out.println(arr[2][3]);//找到的替换过了的数组{111,222,333,444,555}
        //learn中图片二维数组越界问题


        //静态初始化
        int[][] arr = {{11, 22, 33}, {44, 55, 66}, {77, 88, 99}};
        //也可
        int[] arr1={11,22,33};
        int[] arr2={11,22,33};
        int[][] arr3={arr1,arr2};

        //二维数组遍历
        for (int i = 0; i <arr.length ; i++) {
            for (int j = 0; j <arr[i].length ; j++) {
                System.out.println(arr[i][j]);
            }
        }


    }
}
